<template>
    <div>
         <el-table :data="tableData" border  style="width: 100%">
            <el-table-column prop="schId"  label="序号"></el-table-column>
            <el-table-column label="序号">
                <template slot-scope="scope">
                  {{scope.row.onDate}}  于  {{scope.row.location}}  {{scope.row.operation}}
                </template>
            </el-table-column>
            <el-table-column prop="state" :formatter='selectState'  label="状态"></el-table-column>
             <el-table-column  label="操作"  align="center" width="172">
                <template slot-scope="scope">
                  <el-button type="text" size="normally"  @click="edit(scope.row)">{{scope.row.state == '3' ? '查看' : '编辑'}}</el-button>
                </template>
              </el-table-column>
        </el-table>
        <el-pagination class="pageinfo" background layout="prev, pager, next" limit='5'
          @current-change='changeCurrentPage'
          :total="totals">
        </el-pagination>
        <div style="clear:both"></div>
        <el-button class="goback"  type="primary" @click="goback">返回</el-button>
    </div>
 
</template>

<script>
  export default {
    data() {
      return {
        tableData: [],
        currentPage: 1,
        totals: 0
      }
    },
    mounted() {
      this.getTableData()
    },
    methods: {
        changeCurrentPage(page) {
          this.currentPage = page
          this.getTableData()
        },
        edit(row) {
          
            let maintit = row.onDate + '    于     ' + row.location + '       ' + row.operation
            sessionStorage.setItem('maintit', maintit)
            this.$router.push({path: 'activityDayDetail', query: {id: row.schId}})
        },
        goback() {
          this.$router.go(-1)
        },
        selectState(item) {
          
          let text = ''
          switch(item.state) {
            case '1': text = '报名';break;
            case '2': text = '进行中';break;
            case '3': text = '可查看';break;
            default: break;
          }
          return text
        },
        getTableData() {
          let param = {
            eventId: this.$route.query.eventId,
            page: this.currentPage,
            limit: 10
          }
          this.$api.apiGetActivityDayList(param, res => {
              this.tableData = res.data
              this.totals = res.pageInfo.total
          })
        }
    }
  }
</script>
<style lang="scss">
  
</style>
